package com.hb.common.exception;

import com.hb.common.util.Result;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 全局异常处理
 */
@ControllerAdvice
@RestController
@Order(1)
public class GlobalExceptionHandler {

    @ExceptionHandler(DbBackupException.class)
    @ResponseBody
    public Result<Object> handleAllExceptions(DbBackupException e) {
        // 处理所有的异常
        String message = e.getMessage();
        return Result.fail(message);
    }
}
